*** Replication Materials for "Disrupted Learning about Democracy" ***
*** 10/20/22 ***

use "jansa_ringsmuth_PS_public_data_anon_updated_10_21_22.dta"

* table 1 values *
* other values came from Instructors spreadsheet or hand calculations *

mean shifts, over(crn_final)
mean classSize, over(crn_final)
	* to get number of respondents who responded to any wave (total column)
	* to get number of respondents who responded to both waves (w1 and w2 column)
tab crn_final obsType

* figure 1 - distribution of overall handling

histogram shiftMod_overall_w2 if crn_final!=9 & shiftMod_instruction_w2!=10, discrete percent fcolor(gs5) lcolor(black) gap(5) xtitle(, size(medium)) xlabel(0 "Strongly Disagree" 1 "Somewhat Disagree" 2 " " 3" Somewhat Agree" 4 "Strongly Agree", angle(forty_five) valuelabel) legend(all) graphregion(fcolor(white)) 

* Summary stats for overall handling

sum shiftMod_overall_w2 if crn_final!=9 & shiftMod_instruction_w2!=10, detail

/// Model of Overall Instructor Handling of modality shifts

* exclude those in the crn 9 online section of pols 1113 (they did not experience modality shift)
* exclude those who answered that there was no change in modality (shiftMod_instruction_w2!=10)

* using instructor fixed effects

reg shiftMod_overall_w2 ///
	c.shiftMod_instruction_w2 c.shiftMod_tech_w2 c.shiftMod_engage_w2 ///
	i.instructor_final ///
	if crn_final!=9 & shiftMod_instruction_w2!=10
	
*save results using eststo
*if you do not already have this package, install using the following commands:

ssc install estout, replace

*then, use the following commands to see results

eststo overall
esttab overall, star(* .05 ** .01) b(3) se(3) ar2 compress

** Figure 2 ***

*to generate figure, install the coefplot package

ssc install coefplot, replace

*then use the following commands to generate fig 2 coefplot

coefplot, xline(0) title(Instructor Handling of Temporary Changes) subtitle(Instructor Fixed Effects Not Shown) keep(shiftMod_instruction_w2 shiftMod_tech_w2 shiftMod_engage_w2) graphregion(fcolor(white)) xlabel(0(.1)0.5) graphregion(margin(vlarge))

***** ROBUSTNESS CHECKS *****

* same model as above but with student-level controls (and instructor fixed effects)

reg shiftMod_overall_w2 ///
	shiftMod_instruction_w2 shiftMod_tech_w2 shiftMod_engage_w2 ///
	courseAttendance_w2 parentEdu_w1 year_w1 gpa_combo female minority ///
	i.instructor_final ///
	if crn_final!=9 & shiftMod_instruction_w2!=10

* using student-level controls and section fixed effects 

reg shiftMod_overall_w2 ///
	shiftMod_instruction_w2 shiftMod_tech_w2 shiftMod_engage_w2 ///
	courseAttendance_w2 parentEdu_w1 year_w1 gpa_combo /// 
	female minority ///
	i.crn_final  ///
	if crn_final!=9 & shiftMod_instruction_w2!=10

* using section fixed effects and student-level controls, including expected grade

reg shiftMod_overall_w2 shiftMod_instruction_w2 shiftMod_tech_w2  ///
	shiftMod_engage_w2 courseAttendance_w2 parentEdu_w1 year_w1 gpa_combo /// 
	female minority projectedGrade_w2 ///
	i.crn_final ///
	if crn_final!=9 & shiftMod_instruction_w2!=10	
	
***** END ROBUSTNESS CHECKS *****

* knowledge confidence alphas for each wave *

alpha k_parties_w1 k_elections_w1 k_constitution_w1 k_laws_w1 k_branches_w1, item label
alpha k_parties_w2 k_elections_w2 k_constitution_w2 k_laws_w2 k_branches_w2, item label
 * alphas are 0.83 and 0.86 for wave1 and wave2 respectively

* avg growth in knowledge confidence *

sum delta_k

* bivariate comparisons * (p7)

ttest delta_k, by(shiftDum)
tab courseAttendance_w2 shifts, chi2
tab courseEngagement_w2 shifts, chi2

* mean instructor handling * 

sum shiftMod_full

* alpha for instructor handling scale *

* all together * shiftMod_instruction_w2=10 is excluded since it represents no change in modality
* alpha = 0.87
alpha shiftMod_instruction_w2 shiftMod_tech_w2 shiftMod_engage_w2 shiftMod_overall_w2 if shiftMod_instruction_w2!=10, item label

**** Models for Table 2 - Change in Knowledge Confidence Models ****
*primary results for number of shifts and handling shifts on learning

*model 1
mixed delta_k shifts ||instructor_final: ||crn_final:
eststo s1

*model 2
mixed delta_k shifts shiftMod_full ||instructor_final: ||crn_final: if crn_final!=9 & shiftMod_instruction_w2!=10
eststo sm1

*model 3
mixed delta_k c.shifts##c.shiftMod_full k_scale_w1 gpa_combo female minority parentEdu year_w1 ||instructor_final: ||crn_final: if crn_final!=9 & shiftMod_instruction_w2!=10
eststo smod2

esttab s1 sm1 smod2, star(+ .1 * .05 ** .01) b(3) se(3) bic compress

*code for marginal effects plot
margins, dydx(shiftMod_full) at(shifts=(2(1)5)) atmeans
marginsplot

***** ROBUSTNESS CHECKS ******	

* table 2 model 1 with wave 1 knolwedge and demographics; number of shifts not sig (p=0.4)
	
mixed delta_k shifts k_scale_w1 gpa_combo female minority parentEdu year_w1 ||instructor_final: ||crn_final: 

* table 2 model 1 with controls but no wave 1 knowledge; number of shifts is sig (p=0.09)
	
mixed delta_k shifts gpa_combo female minority parentEdu year_w1 ||instructor_final: ||crn_final: 

* table 2 model 1 with controls but no wave 1 knowledge; (shifts p=0.09)

mixed delta_k shifts gpa_combo female minority parentEdu year_w1 ||instructor_final: ||crn_final:
	
* table 2 model 3 without wave 1 knowledge *

mixed delta_k c.shifts##c.shiftMod_full gpa_combo female minority parentEdu year_w1 ||instructor_final: ||crn_final: if crn_final!=9 & shiftMod_instruction_w2!=10

* table 2 model 3 with attendance as a control variable *

mixed delta_k c.shifts##c.shiftMod_full gpa_combo female minority parentEdu year_w1 courseAttendance_w2 ||instructor_final: ||crn_final: if crn_final!=9 & shiftMod_instruction_w2!=10

* table 2 model 3 without wave 1 knowledge and controls *

mixed delta_k c.shifts##c.shiftMod_full ||instructor_final: ||crn_final: if crn_final!=9 & shiftMod_instruction_w2!=10

* code for marginal effects plot * interaction is still sig
margins, dydx(shiftMod_full) at(shifts=(2(1)5)) atmeans
marginsplot

***** END ROBUSTNESS CHECKS *****
